<?php
/*百度短息API调用*/
class SMS106{

	static function send($arr){
		$ch = curl_init();
		$url = 'http://apis.baidu.com/kingtto_media/106sms/106sms?mobile='.$arr['phoneNumber'].'&content='.$arr['content'].'&tag=2';
		$header = array(
			'apikey:'.$arr['apikey'],
		);
		// 添加apikey到header
		curl_setopt($ch, CURLOPT_HTTPHEADER  , $header);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		// 执行HTTP请求
		curl_setopt($ch , CURLOPT_URL , $url);
		$res = curl_exec($ch);

		$log = fopen('SMS106.txt', 'a+');
		fwrite($log, "【".$arr['phoneNumber']."】\t".date('Y-m-d H:i:s')."\n$res\n\n");
		fclose($log);
		return $res;
	}
}
